<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="/layout/main.xhtml">
    <ui:define name="title">Home</ui:define>
    <ui:define name="content">
        <f:metadata>
            <f:viewParam name="resume" id="r" value="#{loginBean.resume}"/>
        </f:metadata>
        <h:form>
            <h:messages showDetail="true" showSummary="true"/>
            <h:panelGroup rendered="#{loginBean.user eq null}">
                <h2>Login</h2>
                <fieldset>
                    <legend>Credentials</legend>
                    <h:panelGrid columns="2">
                        <h:outputLabel value="Username"/>
                        <h:inputText title="Username" value="#{loginBean.username}"/>
                        <h:outputLabel value="Password"/>
                        <h:inputSecret value="#{loginBean.password}"/>
                        <h:outputLabel value=""/>
                        <h:commandButton actionListener="#{loginBean.doLogin}" value="Log in"/>
                    </h:panelGrid>

                </fieldset>
            </h:panelGroup>
            <h:panelGroup rendered="#{loginBean.user ne null}">

                <h2>Logged In</h2>
                You are logged in as #{loginBean.user.name} #{loginBean.user.surname} (#{loginBean.user.email}).
                <br/>
                <h:link outcome="index" value="Return to Index"/>
            </h:panelGroup>
        </h:form>
    </ui:define>
</ui:composition>
